home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hobby PC 32
/
Hobby PC 32.iso
/
extras
/
WIN31
/
DATA.Z
/
VUTILITY.INC
< prev
next >
Wrap
Text File
|
1994-10-25
|
8KB
|
296 lines
'----------------------------------------------------------------
'- more specialized little functions to make our lives easier.
'- John Alspaugh 13OCT94
'- Copyright 1993-1994 Virtus Corporation. All Rights Reserved.
'-
'- Note that this must be included after MSDETECT.INC and SETUPAPI.INC
'-
'----------------------------------------------------------------
'simple utility include.
'' dialog number
CONST LOOKFORFILE_DLG = 6352
CONST NO_WIN_3_1_DLG = 410
CONST WRONG_CPU_DLG = 411
DECLARE SUB VMessageBox(msg$, title$)
DECLARE SUB VDbgMsgBox(msg$, title$)
DECLARE FUNCTION VMakePath (szDir$, szFile$) AS STRING
DECLARE SUB VMaximizeFrame
DECLARE FUNCTION VFindExeFromRegistration(pFExten$, pDest$) AS INTEGER
DECLARE FUNCTION VFindExe(pFName$, pFExten$, pDest$) AS INTEGER
DECLARE FUNCTION VIsSystemAdequate AS INTEGER
'----------------------------------------------------------------
'- Purpose:
'- to have cheap quicky way to message boxes
'- Arguments:
'- the text message and the dialog title
'- Returns:
'- nothing
'----------------------------------------------------------------
SUB VMessageBox(msg$, title$) STATIC
i% = DoMsgBox(msg$, title$, MB_ICONEXCLAMATION+MB_OK)
END SUB
'----------------------------------------------------------------
'- Purpose:
'- to do quicky debug messages
'- Arguments:
'- the text message and the dialog title
'- Returns:
'- nothing
'----------------------------------------------------------------
SUB VDbgMsgBox(msg$, title$) STATIC
'$IFDEF DEBUG
VMessageBox msg$, title$
'$ENDIF 'DEBUG
END SUB
'----------------------------------------------------------------
'- Purpose:
'- Appends a file name to the end of a directory path,
'- inserting a backslash character if needed.
'- Arguments:
'- szDir$ - full directory path (with optional ending "\")
'- szFile$ - filename to append to directory
'- Returns:
'- Resulting fully qualified path name.
'----------------------------------------------------------------
FUNCTION VMakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
VMakePath = szFile$
ELSEIF szFile$ = "" THEN
VMakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
VMakePath = szDir$ + szFile$
ELSE
VMakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION
'----------------------------------------------------------------
'----------------------------------------------------------------
'' From the MS Knowledge Base CD #2:
''following were taken from windows.h. &H means they're hex
CONST WS_VISIBLE=&H10000000
CONST WS_BORDER =&H00800000
CONST WS_CLIPCHILDREN =&H02000000
CONST GWL_STYLE =-16
CONST SW_SHOWMAXIMIZED=3
DECLARE FUNCTION ShowWindow LIB "user.exe" (hWnd%,iShow%) AS INTEGER
DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
SUB VMaximizeFrame STATIC
hWnd%=HwndFrame()
i&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
j%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
END SUB
'----------------------------------------------------------------
'----------------------------------------------------------------
FUNCTION VFindExeFromRegistration (pFExten$, pDest$) STATIC AS INTEGER
'' set the local vars.
lDestDir$ = ""
lDrive$ = ""
CursorSave% = ShowWaitCursor()
'' step one: try to find the file in the win.ini extensions section.
IF pFExten$ <> "" THEN
lDrive$ = GetIniKeyString("WIN.INI", "Extensions", pFExten$)
VDbgMsgBox "Extension entry from Win.ini: " + lDrive$, "VRDEBUG"
IF lDrive$ <> "" THEN ''there is a key
''remove the tail (^.VVR)
StrLen% = LEN(lDrive$)
WHILE (MID$(lDrive$, StrLen%, 1) <> "^") AND (StrLen% > 1)
StrLen% = StrLen% - 1
WEND
StrLen% = StrLen% - 1
TNAME$ = MID$(lDrive$, 1, StrLen%)
lDrive$ = RTRIM$(TNAME$)
StrLen% = DoesFileExist(lDrive$, femExists) '' file still there?
IF StrLen% = 0 THEN
tempStr$ = FindTargetOnEnvVar(lDrive$, "PATH")
IF tempStr$ <> "" THEN
StrLen% = DoesFileExist(tempStr$, femExists)
IF StrLen% = 1 THEN '' file exists
lDrive$ = tempStr$
END IF
END IF
END IF
VDbgMsgBox "After stripping the file type: " + lDrive$, "VRDEBUG"
IF StrLen% = 1 THEN '' file still there!
StrLen% = LEN(lDrive$)
'' Extract directory name
WHILE (MID$(lDrive$, StrLen%, 1) <> "\") AND (StrLen% > 1)
StrLen% = StrLen% - 1
WEND
StrLen% = StrLen% - 1
lDestDir$ = MID$(lDrive$, 1, StrLen%)
VDbgMsgBox "Dir name: " + lDestDir$, "lDestDir"
'' Directory okay?
i% = DoesDirExist(lDestDir$)
IF i% = 0 THEN
lDrive$ = ""
lDestDir$ = ""
END IF
ELSE '' no key. Poop.
lDrive$ = ""
lDestDir$ = ""
END IF
ENDIF
'$IFDEF DEBUG
ELSE
VMessageBox "No file extension passed to VFindExe", "VFindExe Debug"
'$ENDIF 'DEBUG
ENDIF
'' can't find it; punt!
IF lDestDir$ = "" THEN
VDbgMsgBox "Can't find exe anywhere", "VFindExeFromRegistration Debug"
pDest$ = ""
VFindExeFromRegistration = 0
ELSE
pDest$ = lDestDir$
VFindExeFromRegistration = 1
ENDIF
RestoreCursor CursorSave%
END FUNCTION
'----------------------------------------------------------------
'----------------------------------------------------------------
FUNCTION VFindExe (pFName$, pFExten$, pDest$) STATIC AS INTEGER
'$ifdef DEBUG
if pFName$ = "" then
BadArgErr 1, "VFindExe", pFName$
end if
'$endif ''DEBUG
'' set the local vars.
lDestDir$ = ""
lDrive$ = ""
'' step one: try to find the file in the win.ini extensions section.
found% = VFindExeFromRegistration (pFExten, lDestDir$)
'' step two: search the hard drive for the exe.
IF lDestDir$ = "" THEN
dLetter$ = ""
LDList$ = "LocalHardDriveList"
VDbgMsgBox "Can't find exe from win.ini", "VFindExe Debug"
OldCursor% = ShowWaitCursor() '' set waiting cursor
sz$ = UIStartDlg("mscuistf.dll", LOOKFORFILE_DLG, "FModelessDlgProc", 0, "")
GetLocalHardDrivesList LDList$
DListLength% = GetListLength(LDList$)
FOR i% = 1 TO DListLength% STEP 1
dLetter$ = GetListItem(LDList$, i%)
IF (dLetter$ <> "" AND lDestDir$ = "") THEN
lDrive$ = dLetter$ + ":\"
lDestDir$ = FindFileInTree(pFName$, lDrive$)
ENDIF
NEXT i%
VDbgMsgBox "found an exe in " + lDestDir$, "VFindExe"
IF lDestDir$ <> "" THEN
lDrive$ = lDestDir$
StrLen% = LEN(lDrive$)
'' Extract directory name
WHILE (MID$(lDrive$, StrLen%, 1) <> "\") AND (StrLen% > 1)
StrLen% = StrLen% - 1
WEND
StrLen% = StrLen% - 1
lDestDir$ = MID$(lDrive$, 1, StrLen%)
END IF
UIPop 1
RestoreCursor OldCursor%
END IF
'' step three: punt!
IF lDestDir$ = "" THEN
VDbgMsgBox "Can't find exe anywhere", "VFindExe Debug"
pDest$ = ""
VFindExe = 0
ELSE
pDest$ = lDestDir$
VFindExe = 1
ENDIF
END FUNCTION
'----------------------------------------------------------------
'- Purpose:
'- to check if the user's system can handle our stuff.
'- (Win 3.1 on a 386 or better)
'- Arguments:
'- none.
'- Returns:
'- TRUE/FALSE if system is up to our products
'----------------------------------------------------------------
FUNCTION VIsSystemAdequate STATIC AS INTEGER
'' check the windows version and machine type. Verify that it is capable.
WinMajVer% = GetWindowsMajorVersion() '' 3, as in 3.1
WinMinVer% = GetWindowsMinorVersion() '' 10, as in 3.10
Processor% = GetProcessorType() '' 3(86), 4(86), 5(86)
VIsSystemAdequate = 1
IF ((WinMajVer% = 3) AND (WinMinVer% < 10)) OR (WinMajVer < 3) THEN
sz$ = UIStartDlg("mscuistf.dll", NO_WIN_3_1_DLG, "FInfo0DlgProc", 0, "")
UIPop 1
VIsSystemAdequate = 0
ENDIF
IF Processor% < 3 THEN
sz$ = UIStartDlg("mscuistf.dll", WRONG_CPU_DLG, "FInfo0DlgProc", 0, "")
UIPop 1
VIsSystemAdequate = 0
ENDIF
END FUNCTION